// let axiosController = require('./controller/AxiosController')

// async function main() {
//     let axios = new axiosController()
//     let result = await axios.proxy({
//         host: '182.18.13.149',
//         port: '53281',
//         path: `http://data.eastmoney.com/zlsj/detail.aspx?type=ajax&st=2&sr=-1&p=2&ps=30&jsObj=yovImHKb&stat=0&code=600677&date=2017-06-30&rt=51117948`
//     })
//     console.log(result)
// }

// main()


var http = require('http')
var iconv = require('iconv-lite');
var BufferHelper = require('bufferhelper');
let o_url = `http://data.eastmoney.com/zlsj/detail.aspx?type=ajax&st=2&sr=-1&p=2&ps=30&jsObj=yovImHKb&stat=0&code=600677&date=2017-06-30&rt=51117948`

function get(isUseProxy) {
    var url = require('url').parse(o_url);
    let options = {};
    if (isUseProxy) {
        options = {
            host: '112.115.57.20',
            port: '3128',
            method: 'GET',
            path: url.href
        }
    } else {
        options = {
            host: url.host,
            path: url.path,
            method: 'GET'
        }
    }

    http.get(options, function (res) {
        var bufferHelper = new BufferHelper();
        res.on('data', function (chunk) {
            bufferHelper.concat(chunk);
        });
        res.on('end', function () {
            let data = iconv.decode(bufferHelper.toBuffer(), 'UTF-8')
            console.log(data)
        }).on('error', function (e) {
            console.log("Get error: " + e.message);
        })
    })

}

get(true)